﻿@{
    ViewBag.Title = "质控点设置";
}

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/ligerui-icons.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/Gray/css/all.css" rel="stylesheet" />
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script>
        var manager;
        $(function () {
            initTable();
        });


        //加载列表
        function initTable() {
            $("#maingrid").ligerGrid({
                url: '/TraumaCenter/QualityPoint/Search?ram=' + Math.random(),
                columns: [
                    { display: '质控项', name: 'QualityPointTitle', align: 'left', width: 220 }
                    ,
                    {
                        display: '超时比对项', name: 'ComparePointTitle', align: 'left', width: 220
                        //, editor: {
                        //    type: 'select',
                        //    data: [{ id: "1", text: "品牌一" }, { id: "2", text: "品牌二" }],
                        //    valueField: "id",
                        //    textField: "text"
                        //}
                    },
                    { display: '超时时长', name: 'OverTime', align: 'left', width: 220, editor: { type: "number" } },
                    {
                        display: '是否启用', name: 'Status', minWidth: 30, editor: { type: "string" }, render: function (row) {
                            return row.Status == 1 ? "是" : "否";
                        }
                    },
                    { display: '排序', name: 'Sort', minWidth: 20, editor: { type: "string" } },
                    {
                        display: '操作', name: '', minWidth: 180, render: function (rowdata, rowindex, value) {
                            var html = "";
                            if (!rowdata._editing) {
                                html += "<a href='javascript:beginEdit(" + rowdata.Id + ")'>编辑</a> ";
                                if (rowdata.Status==0) {
                                    html += "<a href='javascript:ChangeStatus(" + rowdata.Id + ",1)'>启用</a> ";
                                }
                                else {
                                    html += "<a href='javascript:ChangeStatus(" + rowdata.Id + ",0)'>停用</a> ";
                                }
                            }
                            else {
                                html += "<a href='javascript:endEdit(" + rowindex + ")'>提交</a> ";
                                html += "<a href='javascript:cancelEdit(" + rowindex + ")'>取消</a> ";
                            }
                            return html;
                        }
                    }
                ],
                enabledEdit: true,
                usePager: false,
                rownumbers: true,
                //tree: {
                //    columnName: 'EventName',
                //    idField: 'Id',
                //    parentIDField: 'ParentId'
                //},
                height: '100%',
                heightDiff: 25
            });
        }


        //var AllPointItems;
        //function GetAllPoint() {
        //    $.ajax({
        //        url: '/TraumaCenter/QualityPoint/GetAllPoint?ram=' + Math.random(),
        //        cache: false,
        //        success: function (data) {
                    
        //            AllPointItems = data;
        //            //var temp = $.parseJSON(data);
        //            var tempstr = JSON.stringify(data);
        //            return data;
        //        },
        //        error: function () {
        //            $.ligerDialog.error("程序错误");
        //        }
        //    });
        //}

        function beginEdit(Id) {
            //manager.beginEdit(rowid);
            $.ligerDialog.open({
                height: 360,
                width: 450,
                title: '编辑质控项',
                //data: { Id: Id },
                url: '/TraumaCenter/QualityPoint/Edit?Id=' + Id,
                showMax: false,
                showToggle: false,
                showMin: false,
                isResize: false,
                slide: false,
                buttons: [{
                    text: '回调函数', onclick: function (i, d) {
                        $("#btnSearch").click();
                    }
                }]
            });
            $(".l-dialog-buttons").hide();
        }

        function ChangeStatus(Id, status)
        {
            var editurl = "../QualityPoint/ChangeStatus";
            $.post(editurl, {
                rnd: new Date().getMilliseconds(),
                Status: status,
                Id: Id
            }, function (data) {
                alert(data);
                window.location.reload(); //刷新页面 
            })
        }
        function cancelEdit(rowid) {
            manager.cancelEdit(rowid);
        }
        function endEdit(rowid) {
            manager.endEdit(rowid);
        }
    </script>
</head>
<body>
    <div class="searchbar">
    </div>
    <div id="maingrid"></div>
</body>
</html>

